
include( 'shared.lua' )
include( "resources" )



local function DisallowSpawnMenu( ply )
	if LocalPlayer():IsAdmin() then
		return false
	else return false end
end

hook.Add( "SpawnMenuOpen", "DisallowSpawnMenu", DisallowSpawnMenu)

function GM:PlayerSpray(ply)
	return !ply:IsAdmin()
end

function motd( um )

	local DermaPanel = vgui.Create( "DFrame" )
	DermaPanel:SetPos( 150,50 )
	DermaPanel:SetSize( 600, 500 )
	DermaPanel:SetTitle( "Message of the day" ) -- Title of the frame
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true )
	DermaPanel:ShowCloseButton( true )
	DermaPanel:MakePopup( true )

	function DermaPanel:Paint()
		surface.SetDrawColor( 0, 0, 0, 200 ) -- Set our rect color below us; we do this so you can see items added to this panel
		surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall() ) -- Draw the rect
	end


	local PropertySheet = vgui.Create( "DPropertySheet", DermaPanel )
	PropertySheet:SetPos( 10, 30 )
	PropertySheet:SetSize( 580, 460 )

	local p2 = vgui.Create( "HTML", DermaPanel )
	p2:SetPos( 0, 0 )
	p2:SetSize( 580, 460 )
	p2:SetHTML( file.Read( "CG_FUN/admins.txt" ))

	local motd = vgui.Create( "HTML", DermaPanel )
	motd:SetPos( 0, 0 )
	motd:SetSize( 580, 460 )
	motd:SetHTML( file.Read( "CG_FUN/motd.txt" ) )


	PropertySheet:AddSheet( "Message of the day", motd, "gui/silkicons/world", false, false, "Message of the day" )
	PropertySheet:AddSheet( "Admins", p2, "gui/silkicons/group", false, false, "The admins you need to complain to" )

end

usermessage.Hook("open_motd", motd)


function mahpanel( um )

	local DermaPanel = vgui.Create( "DFrame" )
	DermaPanel:SetPos( 50, 50 )
	DermaPanel:SetSize( 600, 500 )
	DermaPanel:SetTitle( "                                                             -----Citron Gamers Multi Information Desk-----" ) -- Title of the frame
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true )
	DermaPanel:ShowCloseButton( true )
	DermaPanel:MakePopup( true )

	function DermaPanel:Paint()
		surface.SetDrawColor( 0, 0, 0, 200 ) -- Set our rect color below us; we do this so you can see items added to this panel
		surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall() ) -- Draw the rect
	end


	local PropertySheet = vgui.Create( "DPropertySheet", DermaPanel )
	PropertySheet:SetPos( 10, 30 )
	PropertySheet:SetSize( 580, 460 )

	local p1 = vgui.Create( "DPanel", DermaPanel )
	p1:SetPos( 0, 0 )
	p1:SetSize( 580, 460 )

	local p2 = vgui.Create( "HTML", DermaPanel )
	p2:SetPos( 0, 0 )
	p2:SetSize( 580, 460 )
	p2:SetHTML( file.Read( "CG_FUN/admins.txt" ))

	local p3 = vgui.Create( "DPanel", DermaPanel )
	p3:SetPos( 0, 0 )
	p3:SetSize( 580, 460 )

	local motd = vgui.Create( "HTML", DermaPanel )
	motd:SetPos( 0, 0 )
	motd:SetSize( 580, 460 )
	motd:SetHTML( file.Read( "CG_FUN/motd.txt" ) )

	local myLabel= vgui.Create("DLabel", p1)
	myLabel:SetText("This is the Store of Citron Gamers. It is not in use for the moment though")
	myLabel:SizeToContents() // make the control the same size as the text.
	myLabel:SetPos(2,30)
	myLabel:SetTextColor( Color(0, 0, 0, 255) )

	local myLabel2= vgui.Create("DLabel", p1)
	myLabel2:SetText("I have just added the option to trail yourself that works with an earlier mod i made :D")
	myLabel2:SizeToContents() // make the control the same size as the text.
	myLabel2:SetPos(2,45)
	myLabel2:SetTextColor( Color(0, 0, 0, 255) )

	local button = vgui.Create( "DButton", p1 );
	button:SetSize( 100, 30 );
	button:SetPos( 50, 70 );
	button:SetText( "Trail Me" );
	button.DoClick = function( button )
		RunConsoleCommand("~trailme")
	end
	button:SetTextColor( Color(255, 255, 255, 255) )

	local myLabel3= vgui.Create("DLabel", p1 )
	myLabel3:SetText("Sadly, You cannot 'remove' the trail at this time, so you will have to find enougher way to hide from ")
	myLabel3:SizeToContents() // make the control the same size as the text.
	myLabel3:SetPos(2,107)
	myLabel3:SetTextColor( Color(0, 0, 0, 255) )

	local myLabel4= vgui.Create("DLabel", p1 )
	myLabel4:SetText("admins apart from being invisible ;P")
	myLabel4:SizeToContents() // make the control the same size as the text.
	myLabel4:SetPos(2,122)
	myLabel4:SetTextColor( Color(0, 0, 0, 255) )


	local button2 = vgui.Create( "DButton", p1 );
	button2:SetSize( 150, 30 );
	button2:SetPos( 50, 143 );
	button2:SetText( "Connect to Server 1" );
	button2.DoClick = function( ply, button )
		LocalPlayer():ConCommand("connect server.citrongamers.com:27029");
	end
	button2:SetTextColor( Color(255, 255, 255, 255) )

	local myLabel5= vgui.Create("DLabel", p1 )
	myLabel5:SetText("Now you can show your FPS, this is a VERY useful command!")
	myLabel5:SizeToContents() // make the control the same size as the text.
	myLabel5:SetPos(2,180)
	myLabel5:SetTextColor( Color(0, 0, 0, 255) )

	local myCheckBox = vgui.Create( "DCheckBoxLabel", p1 )
	myCheckBox:SetPos( 10, 210 )
	myCheckBox:SetText( "Show FPS ?" )
	myCheckBox:SetConVar( "cl_showfps" )
	myCheckBox:SetValue( 1 )
	myCheckBox:SizeToContents()
	myCheckBox:SetTextColor( Color(0, 0, 0, 255) )

	shop1 = vgui.Create("DImageButton", p3)
	shop1:SetMaterial( "VGUI/entities/npc_mossman" )
	shop1:SetSize(100, 100)
	shop1.DoClick = function()
		Msg("You clicked the button!\n")
	end
	shop1.DoRightClick = function()
        Msg("You right-clicked the button!\n")
    end

	shop2 = vgui.Create("DImageButton", p3)
	shop2:SetMaterial( "VGUI/shopentities/trail-1" )
	shop2:SetPos(103, 0)
	shop2:SetSize(100, 100)
	shop2.DoClick = function()
		RunConsoleCommand("trailme")
	end
	shop2.DoRightClick = function()
        RunConsoleCommand("trailme")
    end


	PropertySheet:AddSheet( "General Information", p1, "gui/silkicons/table_edit", false, false, "Everything and Anything" )
	PropertySheet:AddSheet( "Admins", p2, "gui/silkicons/group", false, false, "The admins you need to complain to" )
	PropertySheet:AddSheet( "Website", motd, "gui/silkicons/world", false, false, "This is our website" )
	PropertySheet:AddSheet( "Shop", p3, "gui/silkicons/emoticon_smile", false, false, "Buy Stuff Here" )


end

usermessage.Hook("open_shoppanel", mahpanel)



function GM:HUDPaint()
	draw.RoundedBox(2, 0, 0, ScrW(), 25, Color(0, 0, 0, 150))
	draw.SimpleText("You are playing the Lobby gamemode made by Ningaglio, Meisno and Alien. Please have fun and spread the word about this server!", "ScoreboardText", ScrW() / 2, 5, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
	draw.RoundedBox(2, 0, ScrH()-25, ScrW(), 25, Color(0, 0, 0, 150))
	draw.SimpleText("Use F3 or the information desk to open the help menu, the shop, a list of the admins and the MOTD", "ScoreboardText", ScrW() / 2, ScrH()-20, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
end


function hidehud(name)
	for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "hidehud", hidehud)


function helppanel()
	local help = vgui.Create( "DFrame" )
	help:SetPos( 50, 50 )
	help:SetSize( 600, 500 )
	help:SetTitle( "The help desk" ) -- Title of the frame
	help:SetVisible( true )
	help:SetDraggable( true )
	help:ShowCloseButton( true )
	help:MakePopup( true )

	function help:Paint()
		surface.SetDrawColor( 0, 0, 0, 200 ) -- Set our rect color below us; we do this so you can see items added to this panel
		surface.DrawRect( 0, 0, help:GetWide(), help:GetTall() ) -- Draw the rect
	end

	local helper = vgui.Create( "DPanel", help )
	helper:SetPos( 25, 25 )
	helper:SetSize( 550, 450 )
	helper:SetHTML( file.Read( "CG_FUN/help.txt" ) )

end

usermessage.Hook("help", helppanel)
